<template>
  <div class="message-list-cont">
      <div class="mess-wrapper" v-for="(item, index) in messageSysListSli" :key="index">
          <div class="mess-left" >
              <div :class="item.isread == 0 ? 'bg blue':'bg grey'"></div>
              <div class="info">
                  <!-- 根据类型判断 -->
                  <!-- 请前往<span class="choose" @click="goToDetail(item,index)">{{'工作池'}}</span> -->
                    {{ item.message }}
                    <!-- {{ item.message[0] }}
                    <span v-if="item.message[1]">
                      <a @click="goToDetail(item.message[1],item)">【{{ item.message[1] }}】</a>
                      {{ item.message[2] }}
                    </span>
                    <span v-if="item.message[3]">
                      <a @click="goToDetail(item.message[3],item)">【{{ item.message[3] }}】</a>
                      {{ item.message[4] }}
                    </span> -->
              </div>
          </div>
          <div class="mess-right">{{item.datetime}}</div>
      </div>
      <div class="message-page">
        <Page v-show="messageSysList.length > 0" @on-change="changePage" :current="currentPage" :total="total" :page-size="pageSize" />
      </div>
      <div class="tc" v-show="messageSysList.length == 0">暂无通知</div>
  </div>
</template>
<script>
// import { routers, appRouter } from "../../../../router";
export default {
  name: 'messSys',
  props: ["messageSysList"],
  data() {
    return {
        messageSysListSli: [],
        currentPage:1,
        pageSize:10,
        total:0,
        // current: "messageSys",
        // messageSys: 1,
        // messageMeet: 0,
        // messageEdu: 5,
        // messageCheck: 0,
        // messageEval: 0,
        // messageKnow: 0,
    };
  },
  methods: {
      goToDetail(name,item){
        let obj={
          type:1,
          idList:item.id
        }
        this.api.updateWorkDiaryReadNotice(obj).then(res => {
          console.log(res)
          this.$store.commit('messageHasChangedFreshedQuickly', 'sys'+item.id);

          let bus = [];
          let routerNames = [];
          // appRouter.forEach((item) => {
          // item.children.forEach((i) =>{
          // if (name.search(item.title) != -1) {
          //   if (name.search("督导件") != -1) {
          //     if (name.search("即将失效保单") != -1) {
          //       this.$router.push({
          //         name: item.name,
          //         query: {
          //           tabIndex: "1",
          //           typeIndex: "3",
          //         },
          //       });
          //       return;
          //     } else {
          //       this.$router.push({
          //         name: item.name,
          //         query: {
          //           tabIndex: "1",
          //         },
          //       });
          //       return;
          //     }
          //   } else if (name.search("收费件") != -1) {
          //     if (name.search("即将失效保单") != -1) {
          //       this.$router.push({
          //         name: item.name,
          //         query: {
          //           tabIndex: "2",
          //           typeIndex: "3",
          //         },
          //       });
          //       return;
          //     } else {
          //       this.$router.push({
          //         name: item.name,
          //         query: {
          //           tabIndex: "2",
          //         },
          //       });
          //       return;
          //     }
          //   } else {
          //     this.$router.push({
          //       name: item.name,
          //     });
          //     return;
          //   }
          // }
          //   if(i.title === name){
          //     this.$router.push({
          //         name: i.name,
          //     })
          //   }
          // })
        // });
        })
          //先置为已读，再跳转
        // this.$router.push({
        //     name:'workPool'
        // })
      },
      changePage(num){
        this.currentPage = num
        this.messageSysListSli = this.messageSysList.slice((this.currentPage-1)*this.pageSize, this.currentPage*this.pageSize)

      }

  },
  watch:{
    messageSysList(){
      console.log("0meetwatch",this.messageSysList)

      this.total = this.messageSysList ? this.messageSysList.length : 0
      this.messageSysListSli = this.messageSysList.slice((this.currentPage-1)*this.pageSize, this.currentPage*this.pageSize)

    }
  },
  mounted() {
      //重置current
      this.currentPage = 1
      this.total = this.messageSysList ? this.messageSysList.length : 0
      this.messageSysListSli = this.messageSysList.slice((this.currentPage-1)*this.pageSize, this.currentPage*this.pageSize)

  }
};
</script>
<style lang="less">
@import "../index.less";
</style>